<?php

/**
 * Log filter form base class.
 *
 * @package    sop
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseLogFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'dt_modif'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'guard_id'      => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUser', 'add_empty' => true)),
      'user_id'       => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUser', 'add_empty' => true)),
      'date'          => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'heure_arrivee' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'heure_depart'  => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'temps_pause'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'total_journee' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'type_id'       => new sfWidgetFormPropelChoice(array('model' => 'TypeJour', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'dt_modif'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'guard_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'sfGuardUser', 'column' => 'id')),
      'user_id'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'sfGuardUser', 'column' => 'id')),
      'date'          => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'heure_arrivee' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'heure_depart'  => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'temps_pause'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'total_journee' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'type_id'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'TypeJour', 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('log_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Log';
  }

  public function getFields()
  {
    return array(
      'dt_modif'      => 'Date',
      'guard_id'      => 'ForeignKey',
      'user_id'       => 'ForeignKey',
      'date'          => 'Date',
      'heure_arrivee' => 'Date',
      'heure_depart'  => 'Date',
      'temps_pause'   => 'Number',
      'total_journee' => 'Number',
      'type_id'       => 'ForeignKey',
      'id'            => 'Number',
    );
  }
}
